
require("TSLib")
local loger = require("loger")
local M = {}

math.randomseed(os.time())

function M.random_values(...)
	v1 = math.random(1)
	v2 = math.random(2)
	v3 = math.random(3)
	v4 = math.random(4)
	v5 = math.random(5)
	v6 = math.random(6)
	return v1,v2,v3,v4,v5,v6
end

function M.click(x,y)
	v1, v2, v3, v4 = M.random_values()
	s1 = math.random(100)
	
	mSleep(s1)
	touchDown(x+v1, y+v2)
	mSleep(s1)
	touchUp(x+v3, y+v4)
	mSleep(s1)
end


function M.double_click(x,y)
	v1, v2, v3, v4 = M.random_values()
	s1 = math.random(100)
	
	touchDown(x+v1, y+v2)
	mSleep(s1)
	touchUp(x+v3, y+v4)
	mSleep(v4)
	touchDown(x+v1, y+v2)
	mSleep(s1)
	touchUp(x+v3, y+v4)
end


function M.slide_down(x, y)
	v1, v2, v3, v4 = M.random_values()
	
	touchDown(x + v1, y+50 + v2)
	touchMove(x + v2, y + v1)
	touchUp(x + v1, y + v2)
	mSleep(100)
end


-- 任务道具切菜单，调用一次翻一个TAB
function M.slide_down_tab(x, y)
	v1, v2, v3, v4 = M.random_values()
	loger.debug("call function: slide_down")
	touchDown(x + v1, y+35)
	mSleep(100)
	--touchMove(x + v2, y+20 + v1)
	touchMove(x + v2, y)
	mSleep(100 + v2)
	touchUp(x + v3, y)
	mSleep(1000 + v1)
end


function M.init_top(x, y)
	-- 拉到顶部
	touchDown(x, y)
	touchMove(x, y+50)
	touchUp(x, y+50)
	mSleep(1000)
	touchDown(x, y)
	touchMove(x, y+50)
	touchUp(x, y+50)
	mSleep(1000)
	touchDown(x, y)
	touchMove(x, y+50)
	touchUp(x, y+50)
	mSleep(2000)
end

function M.main(...)
	init(1);
	for i = 0, 12, 1 do
		M.slide_down(370,450)
	end
end

--M.main()

return M;